package com.miki.sirius.demo.interceptor.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Surging
 * @version 1.0
 * @ClassName WebConfiguration
 * @date 2021/12/29 11:20
 * @desc
 */

@Configuration
public class WebConfiguration implements WebMvcConfigurer {


    //将自定义的拦截器定义为一个bean
//    @Bean
//    public HandlerInterceptor getMyInterceptor(){
//        return new IPInterceptor();
//    }
//
//    @Override
//    public void addInterceptors(InterceptorRegistry registry){
//        // 多个拦截器组成一个拦截器链
//        // addPathPatterns 用于添加拦截规则, 这里假设拦截 /** 后面的全部链接
//        // excludePathPatterns 用户排除拦截
//        registry.addInterceptor(getMyInterceptor()).addPathPatterns("/**");
//    }

}
